package com.wcity.manage.common.utils;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by jn on 2016/11/10.
 * 二维码工具类
 */
public class QRCodeUtil {

    /**
     * 生成二维码bitMatrix 用MatrixToImageWriter输出即可
     * @param content 内容
     * @param width 宽度
     * @param height 高度
     * @return
     */
    public static BitMatrix generateCode( String content, int width, int height ){

        Map<EncodeHintType,Object> hints = new HashMap<>();
        hints.put(EncodeHintType.CHARACTER_SET,"utf-8");
        try {
            return new MultiFormatWriter()
                    .encode(content, BarcodeFormat.QR_CODE,width,height,hints);
        } catch (WriterException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void analyzeCode(){



    }



}
